package com.xpm.adapter.advance;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.xpm.base.BaseAdapter;
import com.xpm.databinding.ItemListViewBinding;
import com.xpm.entity.ItemBean;

/**
 * 继承BaseAdapter使用
 * ItemBean : 实体类
 * ItemListViewBinding : 绑定布局
 * @author xpm
 */
public class ItemListViewAdapter extends BaseAdapter<ItemBean, ItemListViewBinding> {
    @Override
    protected ItemListViewBinding createBinding(LayoutInflater inflater, ViewGroup parent) {
        return ItemListViewBinding.inflate(inflater, parent, false);
    }

    @Override
    protected void bindView(ItemListViewBinding binding, ItemBean item, int position) {
        binding.ivIcon.setImageResource(item.icon);
        binding.tvTitle.setText(item.title);
        Log.i("BaseAdapter bindView", "bindView: "+position);
        //根据条件改变颜色
        if(position%2==0){
            binding.tvTitle.setTextColor(0xFFE91E63);
        }else {
            binding.tvTitle.setTextColor(0xFF2196F3);
        }
    }
}
